package com.quectel.core.module.schedulingapply.dto.vo;


import com.quectel.constant.core.scheduling.SchedulingLeaveConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/7/12 10:21
 * @description new java file header...
 */
@Data
@Schema
public class SchedulingTimeVO {
    @Schema(description = "单位字典值:SchedulingLeaveTimeUnit")
    private Byte timeUnit;
    @Schema(description = "数量")
    private BigDecimal timeLength;

    @Schema(description = "余额详情,在请假时用到,其他场景忽略")
    private List<SchedulingBalanceTimeVO> balanceTimes;

    public BigDecimal getMills() {
        if (timeUnit != null && timeLength != null) {
            SchedulingLeaveConstants.TimeUnitEnum byUnit = SchedulingLeaveConstants.TimeUnitEnum.getByUnit(timeUnit);
            if (byUnit == null) {
                return null;
            }
            return timeLength.multiply(BigDecimal.valueOf(byUnit.getMillis()));
        }
        return null;
    }
}
